import 'package:flutter_frame/common/user_manager.dart';

import '../utils/log_utils.dart';

class AppConfig {
  static final AppConfig _instance = AppConfig._internal();

  factory AppConfig() => _instance;

  // 私有的命名构造函数
  AppConfig._internal();

  //手动定义RELEASE ｜ DEBUG ,用于发布条件的判断
  bool isRelease = true;

  //网络地址
  String? _baseUrl;

  //图片地址
  String? _imgHost;

  //代理
  String? _proxy;

  //渠道
  String? _channel;

  //本地语言
  String? _local;

  //国际时区
  String? _timezone;

  //初始化数据
  initData() async {
    try {
      _baseUrl = "http://10.10.12.133:888";
      _imgHost = "http://img.yunatop.com/";
      _channel = "dptest";
      _local = "en";

      //初始化用户数据
      await UserManager().initData();
    } catch (error) {
      logger(error);
    }
  }

  getBaseUrl() {
    return _baseUrl;
  }

  getProxy() {
    return _proxy;
  }

  getLanguage() {
    return _local;
  }

  getChannel() {
    return _channel;
  }

  //获取集合后图片Host
  String getImageHost() {
    return _imgHost ?? "http://img.yunatop.com/";
  }
}
